package com.seafwg.springboot1.controller;

import com.seafwg.springboot1.service.SayHello;
import com.seafwg.springboot1.vo.SchoolInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @Author seafwg
 * @Date 2022/3/19 9:24 下午
 * @Version 1.0
 * @description xxx
 */
@Controller
@ResponseBody
public class HelloSpring {

    @Resource
    private SchoolInfo schoolInfo;

    @Resource
    private SayHello sayHello;

    // 使用@Value注解注入applicatio.properties文件中的值
    @Value("${dev.id}")
    private Integer id;
    @Value("${dev.name}")
    private String name;

    @RequestMapping("/hello")
    public String springboot() {
        return "hello spring boot";
    }

    @RequestMapping("/school")
    @ResponseBody
    public String schoolInfo() {
        return "devName:  " + name + "  devId:  " + id + "  schoolInfo:  " +schoolInfo.toString();
    }

    // 测试实现run方法的接口
    @RequestMapping("/run")
    public String testRun() {
        sayHello.sayHello();
        return "ok";
    }

}
